<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

$config = [
    'id' => 'app-api',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'api\controllers',
    'bootstrap' => ['log'],
    'modules' => [
        'gps' => [
            'class' => 'api\modules\gps\Gps',
        ],
	    'bank' => [
	    	'class' => 'api\modules\bank\Bank'
	    ],
        'unionpay' => [ // 银联
            'class' => 'api\modules\unionpay\UnionpayModule',
        ],
        'osc' => [
            'class' => 'api\modules\osc\OscModule',
        ],
        'other' => [ // 其他对接
            'class' => 'api\modules\other\OtherModule',
        ],
        'loan' => [ // 借款申请，垫付
            'class' => \api\modules\loan\LoanModule::className(),
        ],
        'proxy_payment' => [ // 其他公司代理收付
            'class' => \api\modules\proxy_payment\ProxyPaymentModule::className(),
        ],
        'chedai' => [ // 车贷系统转移接口
            'class' => \api\modules\chedai\ChedaiModule::className(),
        ],
        'big_data' => [ // 大数据业务
            'class' => \api\modules\big_data\BigDataModule::className(),
        ],
        'insurance' => [ // 保险
            'class' => \api\modules\insurance\InsuranceModule::className(),
        ],
        'haijinchang' => [ // 海金昌
            'class' => \api\modules\haijinchang\HaiJinChang::class,
        ],
        'e_divide' => [ // e分期
            'class' => \api\modules\e_divide\EDivide::class,
        ],
        'icbcapi' => [ // 工行开放平台|融安e信
            'class' => \api\modules\icbcapi\Icbcapi::class,
        ],
        'jzg' => [ // 精真估
            'class' => \api\modules\jzg\JzgModule::class,
        ],
        'nbrb' => [ // 宁波人保
            'class' => \api\modules\nbrb\NbrbModule::class,
        ],
        'collection' => [ // 催收项目
            'class' => api\modules\collection\CollectionModule::class,
        ],
        'dict' => [ // 字典
            'class' => \api\modules\dict\DictModule::class,
        ],
    ],
    'components' => [
        'request' => [
            'enableCsrfValidation' => false,
            'csrfParam' => '_csrf-api',
//            'parsers' => [
//                'application/json' => 'yii\web\JsonParser',
//                'text/json' => 'yii\web\JsonParser',
//            ],
        ],
        'user' => [
            'class' => \common\components\yii_rewrite\web\User::className(),
            'identityClass' => \api\models\User::className(),
            'enableAutoLogin' => true,
            'enableSession' => false,
        ],
        'chedai_user' => [
            'class' => \common\components\yii_rewrite\web\ChedaiUser::className(),
            'identityClass' => \common\models\credit_app\Member::className(),
            'enableAutoLogin' => true,
            'enableSession' => false,
        ],
        'session' => [
            // this is the name of the session cookie used for login on the api
            'name' => 'advanced-api',
        ],
        /*'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],*/
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                'Icbc/get_pic' => 'bank/back/get-pic', // 下载回调的资源
                'Icbc/credit' => 'bank/back/get-submit-credit-bank-back', // 征信回调
                'Icbc/apply_back' => 'bank/back/apply-back', // 申请退回接口
                'Icbc/divi' => 'bank/back/apply-back', //申请退回接口
                'Icbc/credit_card' => 'bank/back/special-card-bank-back', // 专项卡申请退回
                'Icbc/special_card_back' => 'bank/back/special-card-bank-back', // 专项卡申请退回
                'Icbc/get_manual_pics' => 'bank/back/get-manual-pics', // 手工获取图片
                'Icbc/file_list_notice' => 'bank/back/file-list-notice',//文件清单生成通知
                'Icbc/files_created' => 'bank/back/file-list-notice', //文件清单生成通知
            ],
        ],
        'assetManager' => [
            'assetMap' => [
                'AdminLTE.min.css' => '@wrurl/css/AdminLTE.css',
            ],
            'linkAssets' => true,
        ],
    ],
    'params' => $params,
    'as cors' => [
        'class' => \yii\filters\Cors::class,
    ],
    'as token-must-be-check' => [
        'class' => \api\behaviors\TokenCheck::className(),
        'except' => [
            'site/signup',
            'site/get-token-and-key',
            'route/api/index',
	        'test/test/*',
	        'bank/back/*',
            'other/hui-rong/car-invonce-verify-back',
            'other/hui-rong/mortgage-signup-back',
            'unionpay/back/*',
            'chedai/*',
            'dict/*',
            'gii/*',
            'bank/business/download-file-list-info',
            'proxy_payment/business/fuiou-notice-of-dishonour',
            'big_data/validate/report',
            'e_divide/notify/common-back',
            'e_divide/notify/face-validate-report-push',
            'e_divide/default/credit',
            'e_divide/default/credit-confirm',
            'e_divide/default/compensation-associates',
            'e_divide/default/face-validate-report',
            'e_divide/default/face-validate-report-word',
            'jzg/notify/back5',
            'nbrb/notify/*',
            'collection/back/*',
//            '*',
//            'bank/business/*',
        ],
    ],
    'as icbc_ip_filter' => [
        'class' => \api\behaviors\IcbcIpFilter::className(),
        'only' => [
            'bank/back/*',
        ],
    ],
    'as fuiou_ip_filter' => [
        'class' => \api\behaviors\FuiouIpFilter::className(),
        'only' => [
            'proxy_payment/business/fuiou-notice-of-dishonour',
        ],
    ],
    'as chedai-check' => [
        'class' => \api\behaviors\ChedaiCheck::className(),
        'only' => [
            'chedai/*',
            'e_divide/default/credit',
            'e_divide/default/compensation-associates',
        ],
        'except' => [
//            'chedai/*',
            'chedai/others/version-list',
            'chedai/others/last-version-get',
            'chedai/others/last-version-download',
            'chedai/online-verify/*',
//            'chedai/online-verify/check-has-result',
//            'chedai/online-verify/face-sign-check',
//            'chedai/online-verify/get-video-url',
            'chedai/notify/send-ct-notify',
            'chedai/notify/send-estimate-notify',
//            'chedai/unionpay/orders-get3002',
//            'chedai/unionpay/get3002-by-id-card',
            'chedai/unionpay/*',
            'chedai/face-validate/get-face-validate',
            'chedai/ali/get-ali-face-validate-by-idcard',
            'chedai/ali/invoice-info-for-com',
            'chedai/car/car-use-type-loan-check',
            'chedai/car/check-syc',
            'chedai/car/get-all-car-series1',
            'chedai/car/get-all-car-models-by-series-id1',
        ],
        'rules' => [
            [
                'roles' => ['?'],
                'allow' => false,
            ],
            /*[
                'verbs' => ['GET'],
                'allow' => false,
                'denyCallback' => function(){
                    throw new ErrorException('需要post传参');
                }
            ],*/
            [
                'allow' => true,
            ]
        ],
    ],
];

if (YII_ENV_DEV) {
    $config['modules']['test'] = [
        'class' => 'api\modules\test\Test',
    ];
}

$config = yii\helpers\ArrayHelper::merge(
    $config,
    \wodrow\yii\rest\Controller::getConfig()
);

return $config;


